package com.ruoyi.bantong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bantong.domain.BtOrganizationRechargeRecord;
import com.ruoyi.bantong.service.IBtOrganizationRechargeRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构充值记录Controller
 * 
 * @author laohei
 * @date 2021-02-05
 */
@RestController
@RequestMapping("/bantong/orgRechargeRecord")
public class BtOrganizationRechargeRecordController extends BaseController
{
    @Autowired
    private IBtOrganizationRechargeRecordService btOrganizationRechargeRecordService;

    /**
     * 查询机构充值记录列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(BtOrganizationRechargeRecord btOrganizationRechargeRecord)
    {
        startPage();
        List<BtOrganizationRechargeRecord> list = btOrganizationRechargeRecordService.selectBtOrganizationRechargeRecordList(btOrganizationRechargeRecord);
        return getDataTable(list);
    }

    /**
     * 导出机构充值记录列表
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:export')")
    @Log(title = "机构充值记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BtOrganizationRechargeRecord btOrganizationRechargeRecord)
    {
        List<BtOrganizationRechargeRecord> list = btOrganizationRechargeRecordService.selectBtOrganizationRechargeRecordList(btOrganizationRechargeRecord);
        ExcelUtil<BtOrganizationRechargeRecord> util = new ExcelUtil<BtOrganizationRechargeRecord>(BtOrganizationRechargeRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取机构充值记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:query')")
    @GetMapping(value = "/{orrId}")
    public AjaxResult getInfo(@PathVariable("orrId") Integer orrId)
    {
        return AjaxResult.success(btOrganizationRechargeRecordService.selectBtOrganizationRechargeRecordById(orrId));
    }

    /**
     * 新增机构充值记录
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:add')")
    @Log(title = "机构充值记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BtOrganizationRechargeRecord btOrganizationRechargeRecord)
    {
        return toAjax(btOrganizationRechargeRecordService.insertBtOrganizationRechargeRecord(btOrganizationRechargeRecord));
    }

    /**
     * 修改机构充值记录
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:edit')")
    @Log(title = "机构充值记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BtOrganizationRechargeRecord btOrganizationRechargeRecord)
    {
        return toAjax(btOrganizationRechargeRecordService.updateBtOrganizationRechargeRecord(btOrganizationRechargeRecord));
    }

    /**
     * 删除机构充值记录
     */
    //@PreAuthorize("@ss.hasPermi('bantong:record:remove')")
    @Log(title = "机构充值记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orrIds}")
    public AjaxResult remove(@PathVariable Integer[] orrIds)
    {
        return toAjax(btOrganizationRechargeRecordService.deleteBtOrganizationRechargeRecordByIds(orrIds));
    }
}
